package com.bdqn.t382.service.impl;

import com.bdqn.t382.entity.SysUser;
import com.bdqn.t382.mapper.SysUserMapper;
import com.bdqn.t382.service.SysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserServiceImp implements SysUserService {
    private static final Logger LOGGER = LoggerFactory.getLogger(SysUserServiceImp.class);
    // 定义 Mapper
    @Autowired
    private SysUserMapper sysUserMapper;


    @Override
    public List<SysUser> findList(SysUser sysUser) {
        return sysUserMapper.getSysUserList(sysUser);
    }

    @Override
    public SysUser login(String account, String password) {
        SysUser loginUser = sysUserMapper.getByAccount(account);
        // 如果账号存在且密码相等，则返回查到的登录用户信息
        if (loginUser != null && loginUser.getPassword().equals(password)) {
            return loginUser;
        }
        return null;
    }
}
